package com.hitemole.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.hitemole.controller.MenuController;
import com.hitemole.game.GameCore;
import com.hitemole.manager.MenuManager;
import com.hitemole.network.ServerGame;
import com.hitemole.view.MenuRenderer;

public class MenuScreen implements Screen {
	private MenuManager manager;
	private MenuController controller;
	private MenuRenderer renderer;
	private GameCore core;
	
	public MenuScreen(GameCore core) {
		// TODO Auto-generated constructor stub
		this.core=core;
	}
	@Override
	public void render(float delta) {
		// TODO Auto-generated method stub
		Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		controller.update(delta);
		renderer.render();
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
		renderer.setSize(width,height);
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		manager = new MenuManager(core);
		renderer = new MenuRenderer(manager);
		controller = new MenuController(manager);
		Gdx.input.setInputProcessor(manager.getStage());
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		switch(Gdx.app.getType()){
		case Android:
			ServerGame.serverGame.stopServer();
			break;
		case Applet:
			break;
		case Desktop:
			break;
		case WebGL:
			break;
		case iOS:
			break;
		default:
			break;
		}
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		switch(Gdx.app.getType()){
		case Android:
			core.resumeScreen(core.getMenuScreen());
			core.setScreen(core.getResourceScreen());
			break;
		case Applet:
			break;
		case Desktop:
			break;
		case WebGL:
			break;
		case iOS:
			break;
		default:
			break;
		}
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

}
